package com.heima.search.colltroller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.search.pojo.ApUserSearch;
import com.heima.model.common.search.pojo.ArticleDoc;
import com.heima.search.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/history")
public class HistoryColltroller {
   @Autowired
   private HistoryService historyService;

    /**
     * 查询搜索历史的API接口
     * @return
     */
    @PostMapping("/load")
    public ResponseResult<List<ApUserSearch>> load(){
        return historyService.load();
    }
    /**
     * 删除搜索历史的API接口
     * @return
     */
    @PostMapping("/del")
    public ResponseResult del(@RequestBody Map<String,String> map){
        String id = map.get("id");
        return historyService.del(id);
    }
}
